<%--
 *  File:    DateCollateEdit.jsp
 *  @Author: jackwang	
 *  Date:    2013/7/4
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.DateCollateEdit");
  String strModuleName = "IMG";
  String strTableName = "v_datecollate";
  String privilegeCode = "A01001";
  String contextPath = request.getContextPath();

%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@include file="/inc/Print.inc"%>
<html>
<head>
<title>DateCollateEdit.jsp</title>
<PageFlow:CheckPageFlow pageName="p_datecollate"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/cn/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
	Vector searchresults = (Vector)pageContext.getAttribute("searchresults");
	if(searchresults == null) searchresults = new Vector();
	String  isfirst = (String) pageContext.getAttribute("isfirst");
%>
<script>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "DateCollateEdit.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function monthresult(){
	document.cform.actionname.value = "save";
  	document.cform.target = "_self";
  	isRunning = true;
  	document.cform.submit();
}
window.onload=function(){
          // cform.startdate.value=new Date().toFormatString("yyyy-mm-dd");
          // cform.enddate.value=new Date().toFormatString("yyyy-mm-dd");
}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_datecollate">
<input type="hidden" name="isfirst" value="N">
<input type="hidden" name="actionname">
 <input type="hidden" name="numrows" value="<%=searchresults.size() %>"/>
<table width="100%" cellspacing="0">
  <% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
</table>
	<table width="100%">
		 <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" 
                    style="background:url(<%= contextPath %>/images/<%= strLanguageCode %>/title_2_bg.jpg) repeat-x; " height="36">  
         <tr onkeydown="if(event.keyCode==13) page_go();">
          <%
             java.util.Calendar cal = java.util.Calendar.getInstance();    
             String year = cal.get(Calendar.YEAR)+"";     
		     String month = String.valueOf(cal.get(Calendar.MONTH)+1);
		     if(cal.get(Calendar.MONTH) == 0){
				month = "12";
				year = (cal.get(Calendar.YEAR)-1)+"";
			 }  
		  %>
         <td width="8%" class="td_right"><%= label.getLabelName("L_StartTime") + label.getLabelName("L_Colon") %></td>
         <td width="14%" class="td_center">
            <%
            if(!"N".equals(isfirst)){
            %> 
            <custom:selectdic property="startyears" dictType="Years" label="L_Year1" />
		    <custom:selectdic property="startmonths" dictType="Months" label="L_Month" />
		    <%}else{ %>
		    <custom:selectdic property="startyears" dictType="Years" label="L_Year1"  />
		    <custom:selectdic property="startmonths" dictType="Months" label="L_Month" />
		    <%} %>
         </td>
		 <td width="8%" class="td_right"><%= label.getLabelName("L_EndTime") + label.getLabelName("L_Colon") %></td>
         <td width="14%" class="td_center"> 
            <%
            if(!"N".equals(isfirst)){
            %> 
            <custom:selectdic property="endyears" dictType="Years" label="L_Year1" />
		    <custom:selectdic property="endmonths" dictType="Months" label="L_Month"/>
		    <%}else{ %>
		     <custom:selectdic property="endyears" dictType="Years" label="L_Year1" />
		     <custom:selectdic property="endmonths" dictType="Months" label="L_Month"/>
		    <%} %>
         </td>
    
			
         	<td><a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
         <td width="*%" class="td_right">&nbsp;</td>
         </tr>
	</table>
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">


          <tr class="deepblue-left">
            <td width="22" class="title_center" >&nbsp;</td>
              <td width="10%" class="title_center" ><%= label.getLabelName("L_SN") %></td>
            <td width="10%" class="title_center" ><a href="javascript:page_summary('orderby','year')"><%= label.getLabelName("L_Year") %></a></td>
            <td width="10%" class="title_center" ><a href="javascript:page_summary('orderby','month')"><%= label.getLabelName("L_Month") %></a></td>
            <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','toyear')"><%= label.getLabelName("L_StandardYear") %></a></td>
            <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','tomonth')"><%= label.getLabelName("L_StandardMonth") %></a></td>
            <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','datetype')"><%= label.getLabelName("L_Type") %></a></td>
            <td width="10%" class="title_center" ><a href="javascript:page_summary('orderby','datelastupdated')"><%= label.getLabelName("L_Datelastupdate") %></a></td>
          </tr>
          <%
             int j = 0;
             int s=1;
             String strClassType = new String();
             String strIsChecked = "";
             Integer defaultId = new Integer(-1);
             boolean bHasChecked = false;
            
          %>
          <logic:iterate id="pageconfig" collection="<%= searchresults %>" indexId="seq">
          	<%
            HashMap pageConfig = (HashMap)pageContext.getAttribute("pageconfig");
            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "";
            }

           if(!bHasChecked)
            {
              strIsChecked = "Checked";
              defaultId = (Integer)pageConfig.get("datecollateid");
              bHasChecked = true;
              
            }else{
           		strIsChecked = "";
            }
             s= ((Integer)pageConfig.get("datecollateid")).intValue();
            j++;
          %>
          	<tr  class="<%=JspHelper.filterNull(strClassType)%>"
          		onclick="javascript:radiotrue('radio<%=JspHelper.filterNull(j)%>');clickRow('<custom:write name="pageconfig" property="datecollateid" nbsp="true"/>')"
          		>
	            <td width="5%">
	              <input class="normalradio" id="radio<%=JspHelper.filterNull(j)%>" type="radio" name="pageconfig" changedName="fileids" <%=JspHelper.filterNull( strIsChecked)%>>
	            </td>
	            <td>
	               <custom:write  name="pageconfig" property="datecollateid"/>
	            </td>
    	        <td>&nbsp;<custom:write name="pageconfig" property="year" nbsp="true"/></td>
	            <td>&nbsp;<custom:write name="pageconfig" property="month" nbsp="true"/></td>
	            <%
	             cal.setFirstDayOfWeek(Calendar.MONDAY);
	             cal.set(Calendar.DAY_OF_WEEK, 1);
	             java.util.Calendar temp = java.util.Calendar.getInstance();  
	             temp.set(Calendar.YEAR,  ((Integer)pageConfig.get("year")).intValue()); 
	             temp.set(Calendar.MONTH, ((Integer)pageConfig.get("month")).intValue()-1); 
	             temp.setFirstDayOfWeek(Calendar.MONDAY);
	             temp.set(Calendar.DAY_OF_WEEK, 1);
	             //out.print(new java.sql.Date(((Date)temp.getTime()).getTime()));
	             //out.print(new java.sql.Date(((Date)cal.getTime()).getTime()));
	             //out.print(temp.compareTo(cal));
	             if(temp.compareTo(cal)<0){
	            %>
	            <td>&nbsp;&nbsp;<custom:write  name="pageconfig" property="toyear" nbsp="true"/></td>
	            <td>&nbsp;&nbsp;<custom:write  name="pageconfig" property="tomonth" nbsp="true"/></td>
	            <%}else{ %>
	            <custom:hidden name="pageconfig" property="datecollateid" colIndex="<%=seq %>"/>
	            <td>&nbsp;<custom:selectdic name="pageconfig" property="toyear"  dictType="Years"  colIndex="<%=seq %>"/></td>
	            <td>&nbsp;<custom:selectdic name="pageconfig" property="tomonth" dictType="Months" colIndex="<%=seq %>"/></td>
	            <%} %>
	            <td>&nbsp;<custom:write name="pageconfig" property="datetype" dictType="ZylDateType" nbsp="true"  /></td>
	            <td>&nbsp;<custom:write name="pageconfig" property="datelastupdated" nbsp="true"/></td>
	         </tr>
          </logic:iterate>
           
         
          <input type="hidden" name="datecollateid" value="<%=JspHelper.filterNull( defaultId )%>">
          

    <% //--------------------------------------  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>
    <table width="100%">
        <tr> 
          <td class="summary_top"></td>
        </tr>
		<tr >
			  <td class="td_center">
	            <a onclick="monthresult()"><custom:button type="1" label="L_Save" imgsrc="new.gif" border="0" style="width:60"/></a>
	          </td>
	          
		</tr>
	</table>	
   </table>
</form>
</table>


</body>
</html>


